<?php 
    require_once("./system/loginCheck.php");
    require_once("../congfig/config.php");

    $pid=$_POST["pid"];
    $pDesc=$_POST["pDesc"];

    if ($_FILES["Enclosure"]["error"]) {
      switch ($_FILES["Enclosure"]["error"]) {
        case '1':
            echo "文件尺寸超过了配置文件的最大值";
          # code...
          break;
          case '3':
            echo "部分文件上传";
          # code...
          break;
        case '4':
            $sql0="update proinfor set pDesc='$pDesc' where id=$pid";
            $result0=$conn->query($sql0);
            if ($result0==true) {
            	$text="修改成功!";
                header("location:alterProject.php?text=$text&pid=$pid");
            }
          break;
        
        default:
          echo "未知错误";
          break;
      }
      exit;
    }
    $arr=explode(".",$_FILES["Enclosure"]["name"]);
    $suffix=$arr[count($arr)-1];
    
    $filePath="./files/";
   
    $randname=date("YmdHis").rand(100,999).".".$suffix;
   if (move_uploaded_file($_FILES["Enclosure"]["tmp_name"], $filePath.$randname)) {
    echo "文件上传成功"."<br>";
    } 
    $sql="update proinfor set pDesc='$pDesc',Enclosure='$randname' where id=$pid";
    $result=$conn->query($sql);
    if($result==true){
    	$text="修改成功!";
        header("location:alterProject.php?text=$text&pid=$pid");
    }
    else {
    	echo "修改失败!";
    }
 ?>